"""
auth : ginger
    封装 requests
    其实就是一个方法实现 get 和 post , 调用时会自动打印日志 ...
"""
import requests
from common.do_log import do_log


def request(ip='172.16.0.128', port=8081, path='', method: str = None, headers=None, param=None):
    url = 'http://' + ip + ":" + str(port) + path
    do_log.debug('请求接口 : ' + url)
    res = None
    if method.lower() == 'get':
        res = requests.get(url=url, headers=headers, params=param)
    elif method.lower() == 'post':
        res = requests.post(url=url, headers=headers, json=param)
    return res


if __name__ == '__main__':
    response = request(path='/isLogin', method='get')
    print(response)
    print(response.text)
